package com.ewei.support.javax.mail.internet;

import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import org.budo.support.lang.util.UuidUtil;

/**
 * @author li
 * @version 1 (2016年2月17日 下午4:17:27)
 * @since Java7
 */
public class EweiMimeMessage extends MimeMessage {
    public EweiMimeMessage(Session session) {
        super(session);
    }

    protected void updateMessageID() throws MessagingException {
        this.setHeader("Message-ID", "<" + this.getUniqueMessageIdValue(session) + ">");
    }

    private String getUniqueMessageIdValue(Session session) {
        InternetAddress internetAddress = InternetAddress.getLocalAddress(session);
        return UuidUtil.randomUuid() + "-" + internetAddress.getAddress();
    }
}